﻿Imports System.Data.OleDb

Public Class PhonesDetails
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            GridView2.DataSource = SqlDataSource2
            GridView2.DataBind()
        End If

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Dim oleDbcom As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("Phones").ConnectionString)
        oleDbcom.Open()
        Dim sqlString As String = "INSERT INTO Comments(UserName,Title,Body,Phone_fkid) VALUES (@f1,@f2,@f3,@f4)"
        Dim cm As OleDb.OleDbCommand = New OleDb.OleDbCommand(sqlString, oleDbcom)
        cm.CommandType = CommandType.Text
        cm.Parameters.AddWithValue("@f1", User.Identity.Name)
        cm.Parameters.AddWithValue("@f2", tb_CommentTitle.Text)
        cm.Parameters.AddWithValue("@f3", tb_CommentBody.Text)
        cm.Parameters.AddWithValue("@f4", Request.Params("ID"))
        cm.ExecuteNonQuery()
        oleDbcom.Close()
        cm.Dispose()
        oleDbcom.Dispose()
        GridView2.DataSource = SqlDataSource2
        GridView2.DataBind()
        tb_CommentTitle.Text = ""
        tb_CommentBody.Text = ""
        lb_Comment.Text = "Thank you for Adding your Comment"
    End Sub
End Class
